package com.woupla.model;

import java.io.Serializable;
import java.lang.Integer;
import java.lang.String;
import java.util.List;

import javax.persistence.*;
import javax.validation.constraints.NotNull;
import org.hibernate.validator.constraints.NotEmpty;

/**
 * Entity implementation class for Entity: Company
 * 
 */
@NamedQueries(
		{ @NamedQuery(name = "findAllReg", query = "SELECT r FROM Region r ") ,
		 @NamedQuery(name = "findAllRegLike", query = "SELECT r FROM Region r where r.label like :reg order by r.label") ,
		 @NamedQuery(name = "findRegLabel", query = "SELECT r FROM Region r where r.label = :reg")  }
		)
@Entity
public class Region implements Serializable {

	/**
	 * 
	 */
	private static final long serialVersionUID = -4714055814360473722L;

	@Id
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	private Integer id;

	@NotNull
	@NotEmpty
	private String label;
	@NotNull
	@NotEmpty
	private int codeRegion;
	@OneToMany
	private List<Departement>departements;
	/**
	 * @return the id
	 */
	public Integer getId() {
		return id;
	}
	/**
	 * @param id the id to set
	 */
	public void setId(Integer id) {
		this.id = id;
	}
	/**
	 * @return the label
	 */
	public String getLabel() {
		return label;
	}
	/**
	 * @param label the label to set
	 */
	public void setLabel(String label) {
		this.label = label;
	}
	/**
	 * @return the codeRegion
	 */
	public int getCodeRegion() {
		return codeRegion;
	}
	/**
	 * @param codeRegion the codeRegion to set
	 */
	public void setCodeRegion(int codeRegion) {
		this.codeRegion = codeRegion;
	}
	/**
	 * @return the departements
	 */
	public List<Departement> getDepartements() {
		return departements;
	}
	/**
	 * @param departements the departements to set
	 */
	public void setDepartements(List<Departement> departements) {
		this.departements = departements;
	}
	/* (non-Javadoc)
	 * @see java.lang.Object#toString()
	 */
	@Override
	public String toString() {
		StringBuilder builder = new StringBuilder();
		builder.append("Region [label=");
		builder.append(label);
		builder.append("]");
		return builder.toString();
	}
	/* (non-Javadoc)
	 * @see java.lang.Object#hashCode()
	 */
	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + codeRegion;
		result = prime * result
				+ ((departements == null) ? 0 : departements.hashCode());
		result = prime * result + ((label == null) ? 0 : label.hashCode());
		return result;
	}
	/* (non-Javadoc)
	 * @see java.lang.Object#equals(java.lang.Object)
	 */
	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		Region other = (Region) obj;
		if (codeRegion != other.codeRegion)
			return false;
		if (departements == null) {
			if (other.departements != null)
				return false;
		} else if (!departements.equals(other.departements))
			return false;
		if (label == null) {
			if (other.label != null)
				return false;
		} else if (!label.equals(other.label))
			return false;
		return true;
	}

	
	
}
